
#ifndef _ZRXCOPYONWRITEOBJECT_H_H
#define _ZRXCOPYONWRITEOBJECT_H_H
#include "zacbasedefs.h"

#pragma pack(push, 8)

class UcRxCopyOnWriteObject : public UcRxObject
{
public:
	UCRX_DECLARE_MEMBERS_EXPIMP(UcRxCopyOnWriteObject, UCBASE_PORT);

	UCBASE_PORT UcRxCopyOnWriteObject(UcRxObject* pData);
	UCBASE_PORT UcRxCopyOnWriteObject(const UcRxCopyOnWriteObject& other);
	UCBASE_PORT ~UcRxCopyOnWriteObject();
	UCBASE_PORT const UcRxCopyOnWriteObject& operator=(const UcRxCopyOnWriteObject& other);

protected:
	UCBASE_PORT UcRxObject* write();
	UCBASE_PORT const UcRxObject* read() const;
	UCBASE_PORT void unshare();

private:
	void* m_pData;
};

///////////////////////////////////////////////////////////////////////////////
// Defination of helper macros
///////////////////////////////////////////////////////////////////////////////

#define UCRX_DECLARE_MEMBERS_READWRITE(CLASS_NAME, DATA_NAME)   \
	UCRX_DECLARE_MEMBERS(CLASS_NAME);                           \
	DATA_NAME* write()                                          \
{                                                           \
	return (DATA_NAME*)UcRxCopyOnWriteObject::write();      \
}                                                           \
	const DATA_NAME* read() const                           \
{                                                           \
	return (const DATA_NAME*)UcRxCopyOnWriteObject::read(); \
}

#pragma pack(pop)

#endif //_ZRXCOPYONWRITEOBJECT_H_H
